<?php
include ('../configs/cms.php');
include ('includes/connect.php');
include ('classes/cModel.php');

$newsitems = new cModel('nieuws', 'nieuws_id');
$newsitems = $newsitems -> getAll ();

$pages = new cModel ('pagina', 'pagina_id');
$pages = $pages -> getAll ();

foreach ($pages as $page)
{
	if (preg_match ('/(\(module::nieuws\))/', $page -> inhoud, $aMatches))
	{
		$newspage ['id'] = $page -> pagina_id;
		$newspage ['title'] = $page -> titel;
	}
}

foreach ($newsitems as $news)
{
	$aSitemap[] = $_CONFIG ['url'] . $newspage ['id'] . '/' . $newspage ['title'] . '/' . $news -> nieuws_id . '/' . rawurlencode (str_replace (' ', '_', $news -> titel)) . '.html';
}

foreach ($pages as $page)
{
	if (!preg_match ('/(\(module::nieuws\))|(\(module::loguit\))|(gegevens van jezelf)|(\(module::ucp::changepass\))/', $page -> inhoud, $aMatches))
	{
		$aSitemap[] = $_CONFIG ['url'] . $page -> pagina_id . '/' . str_replace (' ', '_', $page -> titel) . '.html';
	}
}

echo'<?xml version="1.0" encoding="UTF-8"?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\r\n";

foreach ($aSitemap as $sUrl)
{
	echo '   <url>
      <loc>' . $sUrl . '</loc>
      <lastmod>' . date ('Y-m-d') . '</lastmod>
      <changefreq>weekly</changefreq>
   </url>' . "\r\n";
}

echo '</urlset>';